<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>mydemo</title>
    <style type="text/css">
      div {
        text-align: center;
      }
    </style>
    <script type="text/javascript">
      window.onload = function () {
        var oNum = document.getElementById("num");
        var i = 0;
        setInterval(sum, 1000);
        sum();
        function sum() {
          oNum.innerHTML = ++i;
        }
      };
    </script>
  </head>
  <body>
    <div><strong id="num"></strong></div>
  </body>
</html>
